/**
 *
 */
package com.naiterui.ehp.bs.doctor.repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bp.domain.DrMessageConsultCharge;
import com.naiterui.ehp.bp.domain.DrMessageConsultChargePK;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 医生图文咨询收费持久层
 *
 * @author guoyongxiang
 * @since 2.7.0
 */
@Repository
public interface IDrMessageConsultChargeRepository extends BaseJpaRepository<DrMessageConsultCharge, DrMessageConsultChargePK> {



    /**
     * 根据医生id和患者列表获取收费金额列表(
     * DrMessageConsultChargeDaoImpl.getChargeListByDoctorId()
     *
     * @param doctorId
     * @return
     *
     * @Author guoyongxiang
     * @Date 2017年4月11日
     * @since 2.7.0
     */
    @Query("from DrMessageConsultCharge where chargePK.doctorId=?1 ")
    List<DrMessageConsultCharge> getChargeListByDoctorId(Long doctorId);


    @Modifying
    @Query(value = "delete from dr_message_consult_charge where doctor_id=?1", nativeQuery = true)
    void deleteChareByDoctorId(Long doctorId);

    @Modifying
    @Query(value = "delete from dr_message_consult_charge where doctor_id=?1 and patient_id in (?2)", nativeQuery = true)
    void deleteChareByDoctorId(Long doctorId, Collection<Long> patientIds);

    void deleteByChargePKIn(List<DrMessageConsultChargePK> ids);

    @Query(value = " from DrMessageConsultCharge where chargePK.doctorId = ?1 and chargePK.patientId in (?2)")
    List<DrMessageConsultCharge> findByDoctorIdAndPatientIdIn(Long doctorId, Collection<Long> patientIds);

}
